package com.tedu.ds.contract.controller;

import com.tedu.ds.base.response.JsonResult;
import com.tedu.ds.contract.pojo.dto.ContractParam;
import com.tedu.ds.contract.pojo.dto.ContractQuery;
import com.tedu.ds.contract.service.ContractService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1/contract")
@Api(tags = "合同模块")
public class ContractController {
    @Autowired
    private ContractService contractService;

    @PostMapping("/select")
    @ApiOperation("查询功能")
    public JsonResult select(@RequestBody ContractQuery contractQuery){
        return JsonResult.ok(contractService.select(contractQuery));
    }

    @PostMapping("/save")
    @ApiOperation("新增和更新功能")
    public JsonResult save(@RequestBody ContractParam contractParam){
        contractService.save(contractParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete")
    @ApiOperation("删除功能")
    public JsonResult delete(@RequestBody ContractParam contractParam){
        contractService.delete(contractParam);
        return JsonResult.ok();
    }
}
